# Copyright (c) 2013 Federico Ruiz Ugalde
# Author: Federico Ruiz-Ugalde <memeruiz at gmail dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

p4a=[
['cwvd', 0x0c, 0x0010, 0xf891, '', 0]
]

p4=[
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0011, 0xc280, '', 0],
['cwvd', 0x0c, 0x0040, 0xc281, '', 0],
['cwvd', 0x0c, 0x0011, 0xc282, '', 0],
['cwvd', 0x0c, 0x0040, 0xc283, '', 0],
['crvd', 0x0b, 0x0000, 0xf891, '', 1, [(0x10, p4a), (0x30, p4a)]]
]

p3a=[
['cwvd', 0x0c, 0x0002, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0006, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0026, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0026, 0xc27d, '', 0]
]+p4

p3b=[
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0]
]+p4

p2c=[
['cwvd', 0x0c, 0x0086, 0xf894, '', 0],
['cwvd', 0x0c, 0x00c0, 0xc0ac, '', 0],
['cwvd', 0x0c, 0x0000, 0xc0ad, '', 0],
['cwvd', 0x0c, 0x0012, 0xc0a2, '', 0],
['cwvd', 0x0c, 0x00e0, 0xc0a3, '', 0],
['cwvd', 0x0c, 0x0028, 0xc0a4, '', 0],
['cwvd', 0x0c, 0x0082, 0xc0a5, '', 0],
['cwvd', 0x0c, 0x0080, 0xc0a7, '', 0],
['cwvd', 0x0c, 0x0014, 0xc000, '', 0],
['cwvd', 0x0c, 0x0003, 0xc006, '', 0],
['cwvd', 0x0c, 0x0099, 0xc090, '', 0],
['cwvd', 0x0c, 0x0090, 0xc091, '', 0],
['cwvd', 0x0c, 0x0068, 0xc094, '', 0],
['cwvd', 0x0c, 0x0070, 0xc095, '', 0],
['cwvd', 0x0c, 0x0030, 0xc09c, '', 0],
['cwvd', 0x0c, 0x00c0, 0xc09d, '', 0],
['cwvd', 0x0c, 0x00e0, 0xc09e, '', 0],
['cwvd', 0x0c, 0x0006, 0xc019, '', 0],
['cwvd', 0x0c, 0x00ba, 0xc08c, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc101, '', 0],
['cwvd', 0x0c, 0x00b3, 0xc10c, '', 0],
['cwvd', 0x0c, 0x0080, 0xc1b2, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc1b4, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc14c, '', 0],
['cwvd', 0x0c, 0x00ca, 0xc14d, '', 0],
['cwvd', 0x0c, 0x0053, 0xc113, '', 0],
['cwvd', 0x0c, 0x008a, 0xc119, '', 0],
['cwvd', 0x0c, 0x0003, 0xc13c, '', 0],
['cwvd', 0x0c, 0x009c, 0xc150, '', 0],
['cwvd', 0x0c, 0x0071, 0xc151, '', 0],
['cwvd', 0x0c, 0x00c6, 0xc152, '', 0],
['cwvd', 0x0c, 0x0084, 0xc153, '', 0],
['cwvd', 0x0c, 0x00bc, 0xc154, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc155, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc156, '', 0],
['cwvd', 0x0c, 0x009c, 0xc157, '', 0],
['cwvd', 0x0c, 0x001f, 0xc158, '', 0],
['cwvd', 0x0c, 0x0006, 0xc159, '', 0],
['cwvd', 0x0c, 0x0000, 0xc15d, '', 0],
['crvd', 0x0b, 0x0000, 0xc27d, '', 1, [(0x00,p3a),(0xa6,p3b)]]
]

p2a=[
['cwvd', 0x0c, 0x000c, 0xf890, '', 0],
['crvd', 0x0b, 0x0000, 0xf894, '', 1, 0x86]
]+p2c

p2b=[
['cwvd', 0x0c, 0x000c, 0xf890, '', 0],
['crvd', 0x0b, 0x0000, 0xf894, '', 1, 0x87]
]+p2c


p2=[
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
['crvd', 0x0b, 0x0000, 0xf890, '', 1, [(0x0c, p2a), (0x8c, p2b)]]
]

p1aa=[
['cwvd', 0x0c, 0x0030, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0030, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
]+p2

p1ab=[
['cwvd', 0x0c, 0x0000, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0010, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0012, 0xc27a, '', 0]
]+p2


p1a=[
['cwvd', 0x0c, 0x0009, 0xc278, '', 0],
['cwvd', 0x0c, 0x000d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['crvd', 0x0b, 0x0000, 0xc279, '', 1, 0x00],
['cwvd', 0x0c, 0x0002, 0xc279, '', 0],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['crvd', 0x0b, 0x0000, 0xc27a, '', 1, [(0x30, p1aa), (0x00, p1ab)]]
]


p1b=[
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['crvd', 0x0b, 0x0000, 0xc279, '', 1, 0x0a],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['crvd', 0x0b, 0x0000, 0xc27a, '', 1, 0x32],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0]
]+p2

p_init=[
['crvd', 0x0b, 0x0000, 0xc278, '', 1, [(0x08, p1a), (0x2d, p1b)]]
]

p_preinit=[ #done during attachment in windows (most probably in the utv driver)
['crvd', 0x02, 0x00a0, 0x00f0, '', 2, (0x01, 0xdb), (True, False)], #0x15 0x9b 0xdb 0xd9
['crvd', 0x07, 0x00a0, 0x0015, '', 2, (0x00, 0x31)],
['crvd', 0x07, 0x00a2, 0x0000, '', 33, (0x00, 0x66, 0x01, 0x01, 0x68, 0x14, 0x14, 0x1f, 0x1f, 0x02, 0x40, 0x09, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x71, 0x1b, 0x01, 0x30, 0x10, 0x31, 0x30, 0x6d, 0x6f, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0020, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x26, 0x55, 0x53, 0x42, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20), [False]*33],
['crvd', 0x07, 0x00a2, 0x0040, '', 33, (0, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0060, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d, 0x71, 0x1b, 0x02, 0x30, 0x12, 0x66, 0x75, 0x73, 0x68, 0x69, 0x63, 0x61, 0x69, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0080, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12, 0x75, 0x73, 0x62, 0x74, 0x76, 0x30, 0x30, 0x37, 0x00, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x00a0, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30), [False]*33],
['crvd', 0x07, 0x00a2, 0x00c0, '', 33, (0, 0x32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x58, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0xf8, 0x33, 0x94), [False]*33],
['crvd', 0x07, 0x00a2, 0x00e0, '', 33, (0x00, 0xf8, 0x87, 0x7a, 0xc2, 0x00, 0x7b, 0xc2, 0x02, 0x7e, 0xc2, 0x01, 0x7f, 0xc2, 0x0b, 0xdc, 0xc1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), [False]*33],
# an interrupt in
['cwvd', 0x0c, 0x0001, 0xc008, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc1d0, '', 0],
['cwvd', 0x0c, 0x0002, 0xc1d9, '', 0],
['cwvd', 0x0c, 0x0013, 0xc1da, '', 0],
['cwvd', 0x0c, 0x0012, 0xc1db, '', 0],
['cwvd', 0x0c, 0x0002, 0xc1e9, '', 0],
['cwvd', 0x0c, 0x006c, 0xc1ec, '', 0],
['cwvd', 0x0c, 0x0030, 0xc25b, '', 0],
['cwvd', 0x0c, 0x0073, 0xc254, '', 0],
['cwvd', 0x0c, 0x0020, 0xc294, '', 0],
['cwvd', 0x0c, 0x00cf, 0xc255, '', 0],
['cwvd', 0x0c, 0x0020, 0xc256, '', 0],
['cwvd', 0x0c, 0x0030, 0xc1eb, '', 0],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0],
['cwvd', 0x0c, 0x0004, 0xc003, '', 0],
['cwvd', 0x0c, 0x0068, 0xc01a, '', 0],
['cwvd', 0x0c, 0x00d3, 0xc100, '', 0],
['cwvd', 0x0c, 0x0072, 0xc10e, '', 0],
['cwvd', 0x0c, 0x00a2, 0xc10f, '', 0],
['cwvd', 0x0c, 0x00b0, 0xc112, '', 0],
['cwvd', 0x0c, 0x0015, 0xc115, '', 0],
['cwvd', 0x0c, 0x0001, 0xc117, '', 0],
['cwvd', 0x0c, 0x002c, 0xc118, '', 0],
['cwvd', 0x0c, 0x0010, 0xc12d, '', 0],
['cwvd', 0x0c, 0x0020, 0xc12f, '', 0],
['cwvd', 0x0c, 0x002e, 0xc220, '', 0],
['cwvd', 0x0c, 0x0008, 0xc225, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x0059, 0xc254, '', 0],
['cwvd', 0x0c, 0x0016, 0xc25a, '', 0],
['cwvd', 0x0c, 0x0035, 0xc25b, '', 0],
['cwvd', 0x0c, 0x0017, 0xc263, '', 0],
['cwvd', 0x0c, 0x0016, 0xc266, '', 0],
['cwvd', 0x0c, 0x0036, 0xc267, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x0040, 0xc239, '', 0],
['cwvd', 0x0c, 0x0000, 0xc240, '', 0],
['cwvd', 0x0c, 0x0000, 0xc241, '', 0],
['cwvd', 0x0c, 0x0002, 0xc242, '', 0],
['cwvd', 0x0c, 0x0080, 0xc243, '', 0],
['cwvd', 0x0c, 0x0012, 0xc244, '', 0],
['cwvd', 0x0c, 0x0090, 0xc245, '', 0],
['cwvd', 0x0c, 0x0000, 0xc246, '', 0],
]

p7=[
['crvd', 0x0b, 0x0000, 0xc245, '', 1, 0x90], #third call 4265f5
['crvd', 0x0b, 0x0000, 0xc242, '', 1, 0x02],
['crvd', 0x0b, 0x0000, 0xc243, '', 1, 0x80], #4 call 4265f5
['crvd', 0x0b, 0x0000, 0xc240, '', 1, 0x00],
['crvd', 0x0b, 0x0000, 0xc241, '', 1, 0x00], #5 call 4265f5
['cwvd', 0x0c, 0x0004, 0xc003, '', 0],
['cwvd', 0x0c, 0x0079, 0xc01a, '', 0],
['cwvd', 0x0c, 0x00d3, 0xc100, '', 0],
['cwvd', 0x0c, 0x0068, 0xc10e, '', 0], #new
['cwvd', 0x0c, 0x009c, 0xc10f, '', 0],
['cwvd', 0x0c, 0x00f0, 0xc112, '', 0],
['cwvd', 0x0c, 0x0015, 0xc115, '', 0],
['cwvd', 0x0c, 0x0000, 0xc117, '', 0],
['cwvd', 0x0c, 0x00fc, 0xc118, '', 0],
['cwvd', 0x0c, 0x0004, 0xc12d, '', 0],
['cwvd', 0x0c, 0x0008, 0xc12f, '', 0],
['cwvd', 0x0c, 0x002e, 0xc220, '', 0],
['cwvd', 0x0c, 0x0008, 0xc225, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0001, 0xc24f, '', 0],
['cwvd', 0x0c, 0x005f, 0xc254, '', 0],
['cwvd', 0x0c, 0x0012, 0xc25a, '', 0],
['cwvd', 0x0c, 0x0001, 0xc25b, '', 0],
['cwvd', 0x0c, 0x001c, 0xc263, '', 0],
['cwvd', 0x0c, 0x0011, 0xc266, '', 0],
#['cwvd', 0x0c, 0x0005, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0005, 0xc267, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x00b8, 0xc16f, '', 0],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10], # 6 call
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88], # 7 call
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0]
]

p6b=[
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0xaa],
['cwvd', 0x0c, 0x0088, 0xc284, '', 0],
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x12],
['crvd', 0x0b, 0x0000, 0xc246, '', 1, 0x00],
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x12]
]+p7

p6a=[
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88], #first call gets to here 42b300
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x11],
['crvd', 0x0b, 0x0000, 0xc246, '', 1, 0xcd], #second call 4265f5
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x11]
]+p7

p5=[
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, [(0x88, p6a), (0xaa, p6b)]]
]
